<template>
  <div>
    <div class="list" v-for="(v,i) in listData" :key="i" @click="routerGo('/detail/'+v.id)">
      <div class="left">
        <img :src="v.image" alt />
      </div>
      <div class="right">
        <div class="title">{{v.name}}</div>
        <div class="detail">{{v.context}}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tag:3,
    };
  },
  computed: {
    listData() {
      return this.$store.state.listData[this.tag];
    }
  },
  created() {
    this.$http.get("/api/list?tag=" + this.tag).then(data => {
      this.$store.commit("setListData", {
        tag: this.tag,
        data: data.data
      });
    });
  },
  methods: {
    routerGo(url) {
      this.$router.push(url)
    }
  }
};
</script>

<style lang='scss' scoped>
.list {
  width: 100%;
  padding: 20px;
  display: flex;
  .left {
    width: 100px;
    height: 100px;
  }
  .right {
    flex: 1;
    padding-left:20px;
    .title {
      font-size: 16px;
      font-weight: bold;
      line-height: 40px;
    }
    .detail {
      font-size: 14px;
      width:calc(100vw - 160px);
      line-height: 30px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}
</style>